﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using JM.JCY.BusinessEntity;
using JM.JCY.Proxy;
using NCS.IConnect.ApplicationContexts;
using JM.JCY.Common;
using JM.JCY.Common.Utilities;
using Microsoft.SharePoint;

namespace JM.JCY.SharePointComponent.IncorruptArchives.CreateSelfControlOverall
{
    public partial class CreateSelfControlOverallUserControl : UserControl
    {
        public string _userName
        {
            set { ViewState["_userName"] = value; }
            get { return (string)ViewState["_userName"]; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (ApplicationContext.Current.UserName != null)
            {
                _userName = ApplicationContext.Current.UserName;
            }

            if (!IsPostBack)
            {
                //this.txtFiller.Text = _userName;
            }
        }

        protected void imgSubmit_Click(object sender, ImageClickEventArgs e)
        {
            using (IncorruptProxy proxy = new IncorruptProxy())
            {
                var newDT = new IncorruptDataSet.T_SelfControl_OverallDataTable();
                var newRow = newDT.NewT_SelfControl_OverallRow();

                newRow.Dept = this.txtDept.Text;
                newRow.Filler = this.txtFiller.Text;
                newRow.FillDate = this.dtFillDate.SelectedDate;
                newRow.Position = this.txtPosition.Text;

                newRow.Option_1 = this.rbOption1.SelectedValue;
                newRow.Option_2 = this.rbOption2.SelectedValue;
                newRow.Option_3 = this.rbOption3.SelectedValue;
                newRow.Option_4 = this.rbOption4.SelectedValue;
                newRow.Option_5 = this.rbOption5.SelectedValue;
                newRow.Option_6 = this.rbOption6.SelectedValue;
                newRow.Option_7 = this.rbOption7.SelectedValue;
                newRow.Option_8 = this.rbOption8.SelectedValue;
                newRow.Option_9 = this.rbOption9.SelectedValue;
                newRow.Option_10 = this.rbOption10.SelectedValue;
                newRow.Option_11 = this.rbOption11.SelectedValue;
                newRow.Option_12 = this.rbOption12.SelectedValue;

                newRow.Remark_1 = this.txtRemark1.Text;
                newRow.Remark_2 = this.txtRemark2.Text;
                newRow.Remark_3 = this.txtRemark3.Text;
                newRow.Remark_4 = this.txtRemark4.Text;
                newRow.Remark_5 = this.txtRemark5.Text;
                newRow.Remark_6 = this.txtRemark6.Text;
                newRow.Remark_7 = this.txtRemark7.Text;
                newRow.Remark_8 = this.txtRemark8.Text;
                newRow.Remark_9 = this.txtRemark9.Text;
                newRow.Remark_10 = this.txtRemark10.Text;
                newRow.Remark_11 = this.txtRemark11.Text;
                newRow.Remark_12 = this.txtRemark12.Text;

                JCYUtility.UpdateCommonFields(newRow, "Iori");
                newDT.AddT_SelfControl_OverallRow(newRow);
                proxy.UpdateSelfControlOverall(newDT);

                Response.Redirect("SelfControlOverall.aspx");
            }


        }

        protected void imgCancel_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("SelfControlOverall.aspx");
        }
    }
}
